﻿using System;
using System.Collections.Generic;

namespace Battle.View
{
    public class CGuideRoundWaitState : RoundWaitState
    {
        CGuideBattleViewCtrl cguideViewCtrl
        {
            get
            {
                return battleRoundCtrl.viewCtrl as CGuideBattleViewCtrl;
            }
        }

        public CGuideRoundWaitState(BattleRoundState state, CGuideBattleRoundCtrl ctrl):base(state, ctrl)
        {

        }

        protected override void CheckGuide()
        {
            if (cguideViewCtrl.curGuideStep == CGuideBattleViewCtrl.GuideStep.Kirito_FirstSkill_Cast && !cguideViewCtrl.isKiritoFirstSkillGuideShow)
            {
                BattleCharacter bc = GetKirito();
                if (bc != null)
                {
                    var heroItem = BattleManager.Instance.battlePanel.GetBattleHeroItem(bc.uniqueId);
                    BattleManager.Instance.battlePanel.guidePanel.Show(heroItem, true, CGuideBattleViewCtrl.GuideStep.Kirito_FirstSkill_Cast);
                    cguideViewCtrl.isKiritoFirstSkillGuideShow = true;
                }
                else
                {
                    cguideViewCtrl.GuideClose();
                }
            }
            else if (cguideViewCtrl.curGuideStep == CGuideBattleViewCtrl.GuideStep.First_Combo_Casting_Last)
            {
                cguideViewCtrl.curGuideStep = CGuideBattleViewCtrl.GuideStep.GuideOver;
                //cguideViewCtrl.curGuideStep = CGuideBattleViewCtrl.GuideStep.Kirito_SecondSkill_Cast;
            }
            else if (cguideViewCtrl.curGuideStep == CGuideBattleViewCtrl.GuideStep.Kirito_SecondSkill_Cast && !cguideViewCtrl.isKiritoSecondSKillGuideShow)
            {
                BattleCharacter bc = GetKirito();
                if (bc != null)
                {
                    var heroItem = BattleManager.Instance.battlePanel.GetBattleHeroItem(bc.uniqueId);
                    BattleManager.Instance.battlePanel.guidePanel.Show(heroItem, true, CGuideBattleViewCtrl.GuideStep.Kirito_SecondSkill_Cast);
                    cguideViewCtrl.isKiritoSecondSKillGuideShow = true;
                }
                else
                {
                    cguideViewCtrl.GuideClose();
                }
            }
            else if (cguideViewCtrl.curGuideStep == CGuideBattleViewCtrl.GuideStep.Second_Combo_Casting_Last)
            {
                cguideViewCtrl.curGuideStep = CGuideBattleViewCtrl.GuideStep.GuideOver;
            }
            else if (cguideViewCtrl.curGuideStep == CGuideBattleViewCtrl.GuideStep.GuideOver && !cguideViewCtrl.isGudieOverShow)
            {
                BattleManager.Instance.battlePanel.guidePanel.Show(null, false, CGuideBattleViewCtrl.GuideStep.GuideOver);
                cguideViewCtrl.isGudieOverShow = true;
            }
        }

        BattleCharacter GetKirito()
        {
            foreach (var actor in cguideViewCtrl.GetAllActors())
            {
                if (actor.Value.heroId == CGuideBattleViewCtrl.kiritoHeroId)
                {
                    return actor.Value;
                }
            }
            return null;
        }


    }
}
